//
//  ViewController.m
//  09-TableViewController
//
//  Created by 王道林 on 16/7/26.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (nonatomic, strong) NSMutableArray *array;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.array = [NSMutableArray arrayWithArray:@[@"唐益梦", @"张合尉", @"高雅馨", @"符淋淋", @"孙遥", @"李毅然", @"于瀚", @"沙长健", @"卢思彤", @"徐昊", @"曹冠雄", @"陈丹明", @"罗浩", @"肖扬", @"王道林", @"宫雪", @"李成", @"冀永金", @"姜浩", @"罗鹏飞", @"李昊林", @"郭宝", @"马峰", @"刘坦奇", @"殷明静", @"邓凯", @"徐康", @"王鍠", @"韩旭", @"杨睿", @"张信宝", @"姜程程", @"包铭礼", @"杜江", @"苗钧豪"]];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"wang"];
    
    //  1. 注意: 这里的self.view  是  tableView
    
    
    //  2 .系统自定义刷新控件. UIRefreshControl
    //   注意 :  UIRefreshControl 有自己的 init 的方法
    //  默认大小  屏幕宽 ,  60高
    
    self.refreshControl = [[UIRefreshControl alloc] init];
    //  可以添加事件,
    
    [self.refreshControl addTarget:self action:@selector(refreshAcition:) forControlEvents:UIControlEventValueChanged];
    
}

// 刷新方法

- (void)refreshAcition:(UIRefreshControl *)refresh
{
    // 延时操作
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        //  刷新控件结束刷新
        [self.refreshControl endRefreshing];
    });
}





- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"wang" forIndexPath:indexPath];
    cell.textLabel.text = _array[indexPath.row];
    return cell;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
